﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Logistics.DataManage.DB;
using MapgisEbp.QuickDataBase;
using System.Data;

namespace Logistics.DataManage.Local
{
    public class LocalDb
    {
        private static DbConfigInfo m_DBConfigInfo = null;

        public static DbConfigInfo DBConfigInfo
        {
            get 
            {
                if (m_DBConfigInfo == null)
                {
                    m_DBConfigInfo = new DbConfigInfo(ConnectStringMgr.ConnectString_Sqlite,"SQLITE");
                }
                return m_DBConfigInfo;
            }
        }
        public static IDataBaseHandler Handler
        {
            get { return DBConfigInfo.DataBaseContext.Handler; }
        }

        private static LocalTableTemplate m_TableTemplates;
        public static LocalTableTemplate TableTemplates
        {
            get{
                if(m_TableTemplates==null)
                    m_TableTemplates = new LocalTableTemplate();
                return m_TableTemplates;
            }
        }

        /// <summary>
        /// 执行sql语句返回影响行数
        /// </summary>
        /// <param name="strSQL">SQL语句</param>
        /// <returns>影响行数</returns>
        public static int ExecuteNonQuery(string strSQL)
        {
            return Handler.ExecuteNonQuery(strSQL);
        }

        /// <summary>
        /// 根据sql语句获取数据集
        /// </summary>
        /// <param name="strSQL">SQL语句</param>
        /// <returns>DataSet</returns>
        public static DataSet ExecuteQuery(string strSQL)
        {
            return Handler.ExecuteQuery(strSQL);
        }
    }
}
